<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateFactoryDevicesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('factory_devices', function (Blueprint $table) {
            $table->unsignedBigInteger('id')->primary();
            $table->enum('status', ['ALREADY','NOT','READONLY'])->default('NOT')->comment('归档状态:NOT未归档ALREADY已归档READONLY只读');
            $table->string('name',255)->default('')->comment('设备名称');
            $table->string('mac_address',255)->default('')->comment('设备mac地址');
            $table->string('unique_id',64)->default('')->comment('设备唯一id')->index('uuid');
            $table->string('connection_password',64)->default('')->comment('设备连接密码');
            $table->unsignedBigInteger('user_id')->default(0)->comment('创建人ID!')->index('user');
            $table->unsignedBigInteger('device_order_id')->default(0)->comment('关联设备生产订单!')->index('order');
            $table->timestamps();
            $table->softDeletes();
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';
            $table->engine = 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('factory_devices');
    }
}
